package band.wukong.practice.java.core.topic.generic;

/**
 * 泛型类
 *
 * @author wukong(wukonggg@139.com)
 */
public class GenericClassSample {

    public static void main(String[] args) {
        Pair<String, String> p1 = new Pair<>("k1", "v1");
        Pair<String, Integer> p2 = new Pair<>("k2", 666);
        System.out.println("p1 = " + p1);
        System.out.println("p2 = " + p2);
    }

    private static class Pair<K, V> {
        private K key;
        private V value;

        Pair(K key, V value) {
            this.key = key;
            this.value = value;
        }

        @Override
        public String toString() {
            return "Pair{" +
                    "key=" + key +
                    ", value=" + value +
                    '}';
        }
    }
}
